﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WebDAV_Test_Application
{
    public class ClassLogger
    {
        private StreamWriter _logStream = null;
        private string _logPath="";
        private bool _logDateAndTime = true;

        public ClassLogger(string LogFile)
        {
            try
            {
                _logStream = File.AppendText(LogFile);
                _logPath = LogFile;
            }
            catch { }
        }

        ~ClassLogger()
        {
            try
            {
                _logStream.Flush();
                _logStream.Close();
            }
            catch { }
        }

        public bool LogDateAndTime
        {
            get { return _logDateAndTime; }
            set { _logDateAndTime = value; }
        }

        public void Log(string Details, string Description="")
        {
            try
            {
                _logStream.WriteLine("");
                _logStream.WriteLine("");
                if (_logDateAndTime)
                    _logStream.WriteLine(String.Format("{0:dd/MM/yy HH:mm:ss}", DateTime.Now) + " ==> " + Description);
                _logStream.WriteLine(Details);
                _logStream.Flush();
            }
            catch { }
        }
    }
}
